<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>web-view</title>
    <style>
      .block {
        width: 100px;
        height: 100px;
        background-color: pink;
      }
    </style>
  </head>
  <body>
    <div class="block"></div>

    <button onclick="sendMessage()">send Message</button>
    <!-- <iframe src="https://cn.vuejs.org/" frameborder="0"></iframe> -->
    <script>
      // window.addEventListener('message', e => {
      //   console.log('e: ', e);
      //   document.querySelector('.block').innerHTML = e.data;

      //   // document.body.innerHTML = JSON.stringify(e.data).toString();
      // });

      const sendMessage = () => {
        window.ReactNativeWebView?.postMessage(
          'message from webview' + Date.now(),
        );
      };
      document.addEventListener('message', e => {
        document.querySelector('.block').innerHTML = e.data;
      });
    </script>
  </body>
</html>
